<?php /*a:1:{s:63:"D:\web\wwwroot\tp5.1\public/../app/admin\view\member\index.html";i:1517457529;}*/ ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表格</title>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body class="body">

<div><a class="layui-btn site-demo-active layui-btn-sm" data-type="tabAdd" id="addmember" data-href="<?php echo url('admin/Member/add'); ?>"><i class="layui-icon">&#xe608;</i>添加会员</a></div>

<div class="layui-form">
  <table class="layui-table" lay-filter="parse-table-demo">
    <thead>
      <tr>
        <th lay-data="{type:'checkbox'}"></th>
        <th lay-data="{field:'id', width:60,sort:true}">ID</th>
        <th lay-data="{field:'user_name', width:150}">用户名</th>
        <th lay-data="{field:'sex', width:60, align:'center'}">性别</th>
        <th lay-data="{field:'nickname', width:150}">简称</th>
        <th lay-data="{field:'email', width:200}">邮箱</th>
        <th lay-data="{field:'login_ip', width:150}">IP</th>
        <th lay-data="{field:'update_time', width:150}">登录时间</th>
        <th lay-data="{field:'create_time', width:150}">注册时间</th>
        <th lay-data="{field:'remark', minwidth:50,edit: 'text'}">备注</th>
        <th lay-data="{field:'status', width:100, toolbar: '#statusTpl'}">状态</th>
        <th lay-data="{fixed: 'right', width:158, align:'center', toolbar: '#barDemo'}">操作</th>
      </tr> 
    </thead>
    <tbody>
<?php foreach($list as $key=>$vo): ?> 
      <tr>
        <td></td>
        <td><?php echo htmlentities($vo['id']); ?></td>
        <td><?php echo htmlentities($vo['user_name']); ?></td>
        <td align="center"><?php echo $vo['sex']==1 ? "男"  :  "女"; ?></td>
        <td><?php echo htmlentities($vo['nickname']); ?></td>
        <td><?php echo htmlentities($vo['email']); ?></td>
        <td><?php echo htmlentities($vo['login_ip']); ?></td>
        <td><?php echo htmlentities(date('Y-m-d H:i',!is_numeric($vo['update_time'])? strtotime($vo['update_time']) : $vo['update_time'])); ?></td>
        <td><?php echo htmlentities(date('Y-m-d H:i',!is_numeric($vo['create_time'])? strtotime($vo['create_time']) : $vo['create_time'])); ?></td>
        <td><?php echo htmlentities($vo['remark']); ?></td>
        <td><?php echo htmlentities($vo['status']); ?></td>
        <td><a href="<?php echo url('admin/Member/edit',['id'=>$vo['id']]); ?>">编辑</a> | <a href="<?php echo url('admin/Member/delete',['id'=>$vo['id']]); ?>">删除</a></td>
      </tr>
<?php endforeach; ?>
    </tbody>
  </table>
</div>
<?php echo $page; ?>

<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i></a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
</script>

<script type="text/html" id="statusTpl">
  <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="禁|否" lay-filter="lockstatus" {{ d.status == 0 ? 'checked' : '' }}>
</script>

<script type="text/javascript" src="/static/frame/layui/layui.js"></script>
<script src="/static/admin/js/comm.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['form', 'table'], function() {
  var $ = layui.jquery,
    form = layui.form,
    table = layui.table;

  table.init('parse-table-demo', { //转化静态表格
    height:'full-120',
    page: false,
    limit: 100,
    id: 'idTest'
  });

  //监听单元格编辑
  table.on('edit(parse-table-demo)', function(obj) {
    var value = obj.value //得到修改后的值
      ,data = obj.data; //得到所在行所有键值
    $.post('<?php echo url('admin/Member/quickedit'); ?>', {
        id: data.id,
        remark: value
      },
      function(data) {
        if (data.code == 1) {
          layer.tips(data.msg, {time: 1000});
        }else{
        layer.msg(data.msg);
      }
      });

  });

  //监听工具条
  table.on('tool(parse-table-demo)', function(obj) {
    var data = obj.data;
    if (obj.event === 'del') {
      layer.confirm('真的删除行么', function(index) {
        //window.location.href = '<?php echo url('delete','',false); ?>/id/' + data.id;
        $.get("<?php echo url('admin/Member/delete'); ?>?id=" + data.id,function(data){
        if (data.code == 1) {
          layer.msg(data.msg);
          obj.del();
          layer.close(index);
        }
        });

      });
    } else if (obj.event === 'edit') {
      layer.open({
        title: "用户信息修改",
        type: 2,
        area: ['550px', '620px'],
        fixed: false, //不固定
        maxmin: true,
        content: "<?php echo url('admin/Member/edit'); ?>?id=" + data.id
      });
    }
  });

  //监听锁定操作
  form.on('switch(lockstatus)', function(obj) {
    if (obj.elem.checked === true) {
      statusval = 0;
    } else {
      statusval = 1;
    }
    $.post('<?php echo url('admin/Member/quickedit'); ?>', {
        id: this.value,
        status: statusval
      },
      function(data) {
        if (data.code == 1) {
          layer.tips(data.msg, obj.othis);
        }else{
        layer.msg(data.msg);
      }
      });

  });

$('#addmember').click(function(){

      layer.open({
        title: "用户信息修改",
        type: 2,
        area: ['550px', '620px'],
        fixed: false, //不固定
        maxmin: true,
        content: $(this).attr('data-href')
      });
});
});
</script>
</body>
</html>